<!--
  This file is a part of the open-eBackup project.
  This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
  If a copy of the MPL was not distributed with this file, You can obtain one at
  http://mozilla.org/MPL/2.0/.
  
  Copyright (c) [2024] Huawei Technologies Co.,Ltd.
  
  THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
  EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
  MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
  -->

<lv-form class="formGroup aui-formGroup-v3">
  <div class="aui-gutter-column-xl">
    <div class="formGroup-h1">{{'system_auth_info_label' | i18n}}</div>
    <lv-form-item *ngIf="isOceanProtect">
      <lv-form-label>
        {{'common_user_type_label' | i18n}}
      </lv-form-label>
      <lv-form-control>
        {{data.userType | textMap:'loginUserType'}}
      </lv-form-control>
    </lv-form-item>
    <lv-form-item>
      <lv-form-label>
        {{ 'common_name_label' | i18n }}
      </lv-form-label>
      <lv-form-control>
        {{data.userName}}
      </lv-form-control>
    </lv-form-item>
    <lv-form-item
      *ngIf="includes([dataMap.loginUserType.local.value,dataMap.loginUserType.ldap.value,dataMap.loginUserType.ldapGroup.value],data.userType)">
      <lv-form-label>
        {{ 'common_login_method_label' | i18n }}
      </lv-form-label>
      <lv-form-control>
        {{data.loginType | textMap:'loginMethod'}}
      </lv-form-control>
    </lv-form-item>
  </div>
  <div class="aui-gutter-column-xl">
    <div class="formGroup-h1">{{'system_other_information_label' | i18n}}</div>
    <lv-form-item *ngIf="data.loginType === dataMap.loginMethod.email.value">
      <lv-form-label>
        {{'system_recipient_email_address_label' | i18n}}
      </lv-form-label>
      <lv-form-control>
        {{data.dynamicCodeEmail}}
      </lv-form-control>
    </lv-form-item>
    <lv-form-item>
      <lv-form-label>
        {{ 'system_user_maxconnections_label' | i18n }}
      </lv-form-label>
      <lv-form-control>
        {{data.sessionControl? data.sessionLimit : '--'}}
      </lv-form-control>
    </lv-form-item>
  </div>
  <ng-container *ngIf="isShowStorage">
    <div class="formGroup-h1">{{'system_auth_storage_label' | i18n}}</div>
    <ng-container *ngIf="isShowUnit">
      <aui-distributed-nas-list [isRbac]="true" [data]="data" [isDetail]="!!data" [isGeneral]="!data"
        [resourceSetMap]="resourceSetMap"></aui-distributed-nas-list>
    </ng-container>
  </ng-container>
  <div class="formGroup-h1">{{'system_associated_role_and_resource_label' | i18n}}</div>
  <div class="formGroup-h2">{{'common_role_label' | i18n}}</div>
  <!--角色下展表及树表-->
  <lv-pro-table #roleDataTable [config]="roleTableConfig" [data]="roleData.tableData"></lv-pro-table>
  <ng-template #treeTableTpl let-item>
    <aui-role-auth-tree [data]="item"></aui-role-auth-tree>
  </ng-template>
  <div class="formGroup-h2">{{'common_resource_set_label' | i18n}}</div>
  <lv-pro-table *ngIf="isShowResourceSet" #resourceDataTable
    [config]="resourceTableConfig" [data]="resourceData.tableData"></lv-pro-table>
  <lv-alert lvType="info"
    *ngIf="!isShowResourceSet">{{'system_built_in_role_resourceset_tip_label' |
    i18n}}</lv-alert>
</lv-form>

<ng-template #roleNameTpl let-item>
  <lv-group lvGutter="6px">
    <span lv-overflow>{{item?.roleName}}</span>
    <lv-tag *ngIf="data.roleId === item?.roleId" [ngModel]="[{label: i18n.get('system_default_role_label')}]"></lv-tag>
  </lv-group>
</ng-template>